// 生成map文件

import * as fs from 'fs-extra'
import * as path from 'path'

// 创建一个新的Map对象
const myMap = new Map<string, number>()
myMap.set('apple', 5)
myMap.set('banana', 3)
myMap.set('orange', 2)

// 将Map对象转为JSON字符串
const mapJson = JSON.stringify(Array.from(myMap.entries()))

// 将JSON字符串写入test.map文件中

const fpath = path.resolve(__dirname, 'test.map')

fs.writeFileSync(fpath, mapJson, 'utf-8')

console.log(`Map对象已写入到${fpath}文件中`)
